package com.example.shengyin.frontController;


import com.example.shengyin.entity.Page;
import com.example.shengyin.service.TeamService;
import com.example.shengyin.util.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("front/team")
@Validated
@CrossOrigin(origins = "*", maxAge = 3600,allowCredentials="true")
@Api(tags = "TeamFrontController", description = "团队")
public class TeamFrontController {

    @Autowired
    private TeamService service;


    @GetMapping("/search")
    @ApiOperation("分页查找")
    public Result team(@ApiParam(name = "tname",value = "团队名") @RequestParam(required = false) String tname,
                       @RequestParam(name = "page", defaultValue= "1") int page,
                       @RequestParam(name = "limit", defaultValue = "10") int limit) {
        Page p = service.selectList(tname, page, limit);
        int count = service.find(tname);
        if(count==0||p==null)
            return Result.error(null);
        return Result.success(p);
    }




}
